<template>
  <div class="seach-container">

    <el-input class="searchInput" v-model="searchInput" @keyup.enter.native="toSearchList">
      <i slot="suffix" class="el-input__icon el-icon-search" @click="toSearchList"></i>
    </el-input>
    <div class="result">
      <div class="left">
        <span v-show="activeName ==1">共搜索到{{total}}条结果</span>
        <span v-show="activeName ==2">共搜索到{{totalNotic}}条结果</span>
        <span v-show="activeName ==3">共搜索到{{totalHcsmng}}条结果</span>
      </div>
      <div class="right">
        <el-tabs v-model="activeName">
          <el-tab-pane v-for="(tab,index) in tabs" :key="index" :name="tab.name" :label="tab.label"></el-tab-pane>
        </el-tabs>
      </div>
    </div>
    <div class="list">
    <template v-if="activeName ==1">
      <div class="body"  v-for="(item,index) in announcmentAllList" :key="index">
        <div class="left">
          <span class="title" v-html="item.name"  @click="navTo('/hj-home/notes/detail/'+item.id)"></span>
          <span class="content" v-html="item.content"  @click="navTo('/hj-home/notes/detail/'+item.id)"></span>
        </div>
        <div class="right">
          <div class="date">
            <span>{{item.createdAt.substring(8,10)}}</span>
            <span v-show="item.createdAt.substring(5,6) == 0 "> {{item.createdAt.substring(6,7)}}月</span>
            <span v-show="item.createdAt.substring(5,6) != 0 "> {{item.createdAt.substring(5,7)}}月</span>
          </div>
          <span class="more"  @click="navTo('/hj-home/notes/detail/'+item.id)">MORE+</span>
        </div>
      </div>
      <el-pagination
      class="dl-pagination"
      :hide-on-single-page="true"
      background
      layout="total, prev, pager, next, jumper"
      :total="total"
      :current-page="queryForm.page"
      :page-size="queryForm.size"
      @current-change="handleCurrentChange"
      prev-text="上一页"
      next-text="下一页"
    />
    </template >
    <template v-else-if="activeName === '2'">
      <div class="body"  v-for="(item,index) in announcmentNoticList" :key="index">
        <div class="left">
          <span class="title" v-html="item.name"  @click="navTo('/hj-home/notes/detail/'+item.id)"></span>
          <span class="content" v-html="item.content"  @click="navTo('/hj-home/notes/detail/'+item.id)"></span>
        </div>
        <div class="right">
          <div class="date">
            <span>{{item.createdAt.substring(8,10)}}</span>
            <span v-show="item.createdAt.substring(5,6) == 0 "> {{item.createdAt.substring(6,7)}}月</span>
            <span v-show="item.createdAt.substring(5,6) != 0 "> {{item.createdAt.substring(5,7)}}月</span>
          </div>
          <span class="more"  @click="navTo('/hj-home/notes/detail/'+item.id)">MORE+</span>
        </div>
      </div>
      <el-pagination
      class="dl-pagination"
      :hide-on-single-page="true"
      background
      layout="total, prev, pager, next, jumper"
      :total="totalNotic"
      :current-page="queryForm.page"
      :page-size="queryForm.size"
      @current-change="handleCurrentChange"
      prev-text="上一页"
      next-text="下一页"
    />
    </template>
    <template v-else-if="activeName === '3'">
      <div class="body"  v-for="(item,index) in announcmentHcsmngList" :key="index">
        <div class="left">
          <span class="title" v-html="item.name"  @click="navTo('/hj-home/notes/detail/'+item.id)"></span>
          <span class="content" v-html="item.content"  @click="navTo('/hj-home/notes/detail/'+item.id)"></span>
        </div>
        <div class="right">
          <div class="date">
            <span>{{item.createdAt.substring(8,10)}}</span>
            <span v-show="item.createdAt.substring(5,6) == 0 "> {{item.createdAt.substring(6,7)}}月</span>
            <span v-show="item.createdAt.substring(5,6) != 0 "> {{item.createdAt.substring(5,7)}}月</span>
          </div>
          <span class="more"  @click="navTo('/hj-home/notes/detail/'+item.id)">MORE+</span>
        </div>
      </div>
      <el-pagination
      class="dl-pagination"
      :hide-on-single-page="true"
      background
      layout="total, prev, pager, next, jumper"
      :total="totalHcsmng"
      :current-page="queryForm.page"
      :page-size="queryForm.size"
      @current-change="handleCurrentChange"
      prev-text="上一页"
      next-text="下一页"
    />
    </template>

    </div>
    <!-- <el-pagination
      class="dl-pagination"
      :hide-on-single-page="true"
      background
      layout="total, prev, pager, next, jumper"
      :total="total"
      :current-page="queryForm.page"
      :page-size="queryForm.size"
      @current-change="handleCurrentChange"
      prev-text="上一页"
      next-text="下一页"
    /> -->
  </div>
</template>

<script>
import { announcmentListAPI,policyListAPI,ruleListAPI } from '@/api/announcmentList.js'
export default {
  data () {
    return {
      searchInput:'',
      activeName:'1',
      tabs:[{
        name:'1',
        label:'全部'
      },
      {
        name:'2',
        label:'通知公告'
      },
      {
        name:'3',
        label:'规章制度'
      }],
      announcmentAllList:[],
      announcmentNoticList:[],
      announcmentHcsmngList:[],
      queryForm: {
				  page: 0,
				  name: '',
          size:5,
      },
      tagName: '',
      totalHcsmng: 0,
      total:0,
      totalNotic:0,
    }
  },

  created () {
    // this.queryList()
    this.searchInput = this.$route.params.name
    this.toSearchList()
  },

  methods: {
    toSearchList(){
      this.queryForm.page = 1
		  this.queryList()
    },
    queryList() {
      this.loading = true
      announcmentListAPI({page:this.queryForm.page-1,size:5,sort:'createdAt,desc',name:this.searchInput,content:this.searchInput}).then(res => {
        this.loading = false
        this.announcmentAllList = res.content
        this.total =res.totalElements
      }).catch(_ => {
    	    this.loading = false
    	  })
      policyListAPI({page:this.queryForm.page-1,size:5,sort:'createdAt,desc',name:this.searchInput,content:this.searchInput}).then(res => {
        this.loading = false
        this.announcmentNoticList = res.content
        this.totalNotic =res.totalElements
      }).catch(_ => {
        this.loading = false
      })
      ruleListAPI({page:this.queryForm.page-1,size:5,sort:'createdAt,desc',name:this.searchInput,content:this.searchInput}).then(res => {
        this.loading = false
        this.announcmentHcsmngList = res.content
        this.totalHcsmng =res.totalElements
      }).catch(_ => {
        this.loading = false
      })
    },
    handleCurrentChange(val) {
		this.queryForm.page = val
		this.queryList()
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.seach-container ::v-deep {
    position: relative;
    min-height: 1300px;
    padding: 0 80px;
    .el-pagination {
      position: absolute;
      bottom: 0;
      margin:0 470px;
      display: flex;
      align-items: center;
      color: #707070;
    }
    .el-pagination span:not([class*=suffix]), .el-pagination button {
      font-size: 18px;
      margin: 0 10px;
    }
    .el-pagination__jump {
      display: flex;
      align-items: center;
    }
    .el-pagination__editor.el-input {
      display: flex;
      align-items: center;
      width: 120px;
    }
    .el-pagination__editor.el-input .el-input__inner,
    .el-pagination.is-background .btn-prev,
    .el-pagination.is-background .btn-next,
    .el-pagination.is-background .el-pager li {
      background-color: #fff;
      width: 80px;
      font-size: 16px;
      height: 50px;
      border: 1px solid #707070;
      color: #707070;
      margin: 0 10px;
    }
    .el-pagination.is-background .el-pager li {
      line-height: 50px;
    }

    .el-pagination.is-background
    .el-pager li:not(.disabled).active {
      color:#fff;
      background-color: #065795;
    }
  }
.searchInput ::v-deep{
  margin-top: 98px;
  height: 80px;
  .el-input__inner{
    font-size: 22px;
    height: 80px;
    border-radius: 15px;
    border: 1px solid #707070;
  }
  .el-input__icon{
    font-size: 30px;
    margin-right: 20px;
    line-height: 80px;
  }
}
  .result{
    display: flex;
    border-bottom: 1px solid #A5A5A5;
    color: #999999;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 25px;
    height: 120px;
    // align-items: center;
    .left{
      width: 70%;
      padding-bottom: 15px;
    }
    .right ::v-deep{
      width: 30%;

      .el-tabs,
      .el-tabs__header {
        margin-bottom: 0;
      }
      .el-tabs__item{
        font-size: 25px;
      }
      .el-tabs__item.is-active{
        color:#074489;
      }
      .el-tabs__nav-wrap::after{
        background-color: unset;
      }
      .el-tabs__active-bar{
        background-color: unset;
      }
      .el-tabs__nav{
        float: unset;
        display: flex;
        justify-content: space-around;
      }
    }
  }
  .body{
    width:1260px;
    height: 188px;
    border: 1px solid #707070;
    border-radius: 5px;
    display: flex;
    justify-content: space-around;
   margin-bottom: 60px;
    background: #fff;
    .left{
      width: 80%;
      height: 188px;
      margin: 40px 0 0 40px;;
      .title{
        width: 95%;
        height: 50px;
        font-size: 28px;
        display:block;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        cursor: pointer;
      }
      .content{
        width: 95%;
        line-height: 28px;
        font-size: 18px;
        color: #999999;
        display:block;
        overflow: hidden;
        text-overflow: ellipsis;
        display:-webkit-box;
        -webkit-box-orient:vertical;
        -webkit-line-clamp:2;
        cursor: pointer;
      }
    }
    .right{
      width: 15%;
      height: 188px;
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-top: 40px;
      .date{
      width: 65px;
      height: 63px;
      background: #074489;
      border-radius: 6px;
      font-size: 16px;
      padding: 6px;
      color: #fff;
      display: flex;
      flex-direction: column;
      align-items: center;
      span:nth-child(1) {
        font-size: 25px;
        font-weight: bold;
      }
      span:nth-child(2) {
          font-size: 16px;
          font-weight: 400;
          line-height: 20px;
      }
    }
      .more{
        font-size: 18px;
        color: #444444;
        padding-top: 40px;
        cursor: pointer;
      }
    }

  }
  .list {
     padding-top: 60px;
      min-height: 1400px;
      display: flex;
      align-items: center;
      flex-direction: column;
    }
</style>
